package com.example.grpc.remote;

import static io.grpc.stub.ClientCalls.asyncUnaryCall;
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
import static io.grpc.stub.ClientCalls.futureUnaryCall;
import static io.grpc.MethodDescriptor.generateFullMethodName;
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;

/**
 */
@javax.annotation.Generated(
    value = "by gRPC proto compiler (version 1.4.0)",
    comments = "Source: UserService.proto")
public final class UserServiceGrpc {

  private UserServiceGrpc() {}

  public static final String SERVICE_NAME = "UserService";

  // Static method descriptors that strictly reflect the proto.
  @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
  public static final io.grpc.MethodDescriptor<RApiCompany,
      RApiUser> METHOD_SEARCH_USERS_BY_COMPANY =
      io.grpc.MethodDescriptor.<RApiCompany, RApiUser>newBuilder()
          .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
          .setFullMethodName(generateFullMethodName(
              "UserService", "searchUsersByCompany"))
          .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
              RApiCompany.getDefaultInstance()))
          .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
              RApiUser.getDefaultInstance()))
          .build();
  @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
  public static final io.grpc.MethodDescriptor<RApiCompany,
      RApiUser> METHOD_SEARCH_USERS_BY_COMPANIES =
      io.grpc.MethodDescriptor.<RApiCompany, RApiUser>newBuilder()
          .setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
          .setFullMethodName(generateFullMethodName(
              "UserService", "searchUsersByCompanies"))
          .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
              RApiCompany.getDefaultInstance()))
          .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
              RApiUser.getDefaultInstance()))
          .build();
  @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
  public static final io.grpc.MethodDescriptor<RApiUserRegisterRequest,
      RApiUserRegisterResponse> METHOD_REGISTER =
      io.grpc.MethodDescriptor.<RApiUserRegisterRequest, RApiUserRegisterResponse>newBuilder()
          .setType(io.grpc.MethodDescriptor.MethodType.UNARY)
          .setFullMethodName(generateFullMethodName(
              "UserService", "register"))
          .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
              RApiUserRegisterRequest.getDefaultInstance()))
          .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
              RApiUserRegisterResponse.getDefaultInstance()))
          .build();

  /**
   * Creates a new async stub that supports all call types for the service
   */
  public static UserServiceStub newStub(io.grpc.Channel channel) {
    return new UserServiceStub(channel);
  }

  /**
   * Creates a new blocking-style stub that supports unary and streaming output calls on the service
   */
  public static UserServiceBlockingStub newBlockingStub(
      io.grpc.Channel channel) {
    return new UserServiceBlockingStub(channel);
  }

  /**
   * Creates a new ListenableFuture-style stub that supports unary calls on the service
   */
  public static UserServiceFutureStub newFutureStub(
      io.grpc.Channel channel) {
    return new UserServiceFutureStub(channel);
  }

  /**
   */
  public static abstract class UserServiceImplBase implements io.grpc.BindableService {

    /**
     */
    public void searchUsersByCompany(RApiCompany request,
                                     io.grpc.stub.StreamObserver<RApiUser> responseObserver) {
      asyncUnimplementedUnaryCall(METHOD_SEARCH_USERS_BY_COMPANY, responseObserver);
    }

    /**
     */
    public io.grpc.stub.StreamObserver<RApiCompany> searchUsersByCompanies(
        io.grpc.stub.StreamObserver<RApiUser> responseObserver) {
      return asyncUnimplementedStreamingCall(METHOD_SEARCH_USERS_BY_COMPANIES, responseObserver);
    }

    /**
     */
    public void register(RApiUserRegisterRequest request,
                         io.grpc.stub.StreamObserver<RApiUserRegisterResponse> responseObserver) {
      asyncUnimplementedUnaryCall(METHOD_REGISTER, responseObserver);
    }

    @Override public final io.grpc.ServerServiceDefinition bindService() {
      return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
          .addMethod(
            METHOD_SEARCH_USERS_BY_COMPANY,
            asyncServerStreamingCall(
              new MethodHandlers<
                RApiCompany,
                RApiUser>(
                  this, METHODID_SEARCH_USERS_BY_COMPANY)))
          .addMethod(
            METHOD_SEARCH_USERS_BY_COMPANIES,
            asyncBidiStreamingCall(
              new MethodHandlers<
                RApiCompany,
                RApiUser>(
                  this, METHODID_SEARCH_USERS_BY_COMPANIES)))
          .addMethod(
            METHOD_REGISTER,
            asyncUnaryCall(
              new MethodHandlers<
                RApiUserRegisterRequest,
                RApiUserRegisterResponse>(
                  this, METHODID_REGISTER)))
          .build();
    }
  }

  /**
   */
  public static final class UserServiceStub extends io.grpc.stub.AbstractStub<UserServiceStub> {
    private UserServiceStub(io.grpc.Channel channel) {
      super(channel);
    }

    private UserServiceStub(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @Override
    protected UserServiceStub build(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      return new UserServiceStub(channel, callOptions);
    }

    /**
     */
    public void searchUsersByCompany(RApiCompany request,
                                     io.grpc.stub.StreamObserver<RApiUser> responseObserver) {
      asyncServerStreamingCall(
          getChannel().newCall(METHOD_SEARCH_USERS_BY_COMPANY, getCallOptions()), request, responseObserver);
    }

    /**
     */
    public io.grpc.stub.StreamObserver<RApiCompany> searchUsersByCompanies(
        io.grpc.stub.StreamObserver<RApiUser> responseObserver) {
      return asyncBidiStreamingCall(
          getChannel().newCall(METHOD_SEARCH_USERS_BY_COMPANIES, getCallOptions()), responseObserver);
    }

    /**
     */
    public void register(RApiUserRegisterRequest request,
                         io.grpc.stub.StreamObserver<RApiUserRegisterResponse> responseObserver) {
      asyncUnaryCall(
          getChannel().newCall(METHOD_REGISTER, getCallOptions()), request, responseObserver);
    }
  }

  /**
   */
  public static final class UserServiceBlockingStub extends io.grpc.stub.AbstractStub<UserServiceBlockingStub> {
    private UserServiceBlockingStub(io.grpc.Channel channel) {
      super(channel);
    }

    private UserServiceBlockingStub(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @Override
    protected UserServiceBlockingStub build(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      return new UserServiceBlockingStub(channel, callOptions);
    }

    /**
     */
    public java.util.Iterator<RApiUser> searchUsersByCompany(
        RApiCompany request) {
      return blockingServerStreamingCall(
          getChannel(), METHOD_SEARCH_USERS_BY_COMPANY, getCallOptions(), request);
    }

    /**
     */
    public RApiUserRegisterResponse register(RApiUserRegisterRequest request) {
      return blockingUnaryCall(
          getChannel(), METHOD_REGISTER, getCallOptions(), request);
    }
  }

  /**
   */
  public static final class UserServiceFutureStub extends io.grpc.stub.AbstractStub<UserServiceFutureStub> {
    private UserServiceFutureStub(io.grpc.Channel channel) {
      super(channel);
    }

    private UserServiceFutureStub(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @Override
    protected UserServiceFutureStub build(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      return new UserServiceFutureStub(channel, callOptions);
    }

    /**
     */
    public com.google.common.util.concurrent.ListenableFuture<RApiUserRegisterResponse> register(
        RApiUserRegisterRequest request) {
      return futureUnaryCall(
          getChannel().newCall(METHOD_REGISTER, getCallOptions()), request);
    }
  }

  private static final int METHODID_SEARCH_USERS_BY_COMPANY = 0;
  private static final int METHODID_REGISTER = 1;
  private static final int METHODID_SEARCH_USERS_BY_COMPANIES = 2;

  private static final class MethodHandlers<Req, Resp> implements
      io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
    private final UserServiceImplBase serviceImpl;
    private final int methodId;

    MethodHandlers(UserServiceImplBase serviceImpl, int methodId) {
      this.serviceImpl = serviceImpl;
      this.methodId = methodId;
    }

    @Override
    @SuppressWarnings("unchecked")
    public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
      switch (methodId) {
        case METHODID_SEARCH_USERS_BY_COMPANY:
          serviceImpl.searchUsersByCompany((RApiCompany) request,
              (io.grpc.stub.StreamObserver<RApiUser>) responseObserver);
          break;
        case METHODID_REGISTER:
          serviceImpl.register((RApiUserRegisterRequest) request,
              (io.grpc.stub.StreamObserver<RApiUserRegisterResponse>) responseObserver);
          break;
        default:
          throw new AssertionError();
      }
    }

    @Override
    @SuppressWarnings("unchecked")
    public io.grpc.stub.StreamObserver<Req> invoke(
        io.grpc.stub.StreamObserver<Resp> responseObserver) {
      switch (methodId) {
        case METHODID_SEARCH_USERS_BY_COMPANIES:
          return (io.grpc.stub.StreamObserver<Req>) serviceImpl.searchUsersByCompanies(
              (io.grpc.stub.StreamObserver<RApiUser>) responseObserver);
        default:
          throw new AssertionError();
      }
    }
  }

  private static final class UserServiceDescriptorSupplier implements io.grpc.protobuf.ProtoFileDescriptorSupplier {
    @Override
    public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
      return RemoteUserService.getDescriptor();
    }
  }

  private static volatile io.grpc.ServiceDescriptor serviceDescriptor;

  public static io.grpc.ServiceDescriptor getServiceDescriptor() {
    io.grpc.ServiceDescriptor result = serviceDescriptor;
    if (result == null) {
      synchronized (UserServiceGrpc.class) {
        result = serviceDescriptor;
        if (result == null) {
          serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
              .setSchemaDescriptor(new UserServiceDescriptorSupplier())
              .addMethod(METHOD_SEARCH_USERS_BY_COMPANY)
              .addMethod(METHOD_SEARCH_USERS_BY_COMPANIES)
              .addMethod(METHOD_REGISTER)
              .build();
        }
      }
    }
    return result;
  }
}
